#include <iostream>
#include <Kokkos_Core.hpp>

int main(int argc, char* argv[]) {
  Kokkos::initialize();
  {
    int N = 10;  

    Kokkos::View<double*> x("X", N);

    Kokkos::deep_copy(x, 2.0);

    // Kokkos::parallel_for("assignment", N, [=] (int i) {
        // x(i) = 1.0; 
        // });

    double sum = 0.0;
    Kokkos::parallel_reduce(
        "square", N, [=](int i, double& tmp) { 
        tmp += x(i) * x(i); },
        sum);

    std::cout << sum << std::endl;
  }
  Kokkos::finalize();
}